package com.ftg.learn.util;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author Guo
 * @date 2022/3/8
 */
@CrossOrigin(origins = "http://26.234.93.45")
public class SelectController <E,T extends IService<E>>{


    @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
    @Autowired
    public T service;

    ResEntity re = new ResEntity();

    @GetMapping("/showAll")
    @ApiOperation(value = "通用无条件查询功能")
    public ResEntity showAll() {
        return re.OK(service.list());
    }

    @GetMapping("/page")
    @ApiOperation(value = "分页功能")
    public ResPageEntity page(@RequestParam int page, @RequestParam int limit){
        IPage<E> p = new Page<>(page,limit);
        service.page(p);
        return new ResPageEntity(p);
    }



}
